package com.rikao.controller;

import com.rikao.pojo.Emp;
import com.rikao.service.EmpService;
import entity.Result;
import entity.StatusCode;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/emp")
@RestController
@CrossOrigin
public class EmpController {
    @Resource
    private EmpService empService;

    @GetMapping
    public Result findlike(@RequestBody Emp emp){

        return new Result(true, StatusCode.OK,"查询成功",empService.findlike(emp.getAdress()));
    }

    @PostMapping
    public Result add(@RequestBody Emp emp){
        empService.add(emp);
        return new Result(true,StatusCode.OK,"新增成功",null);
    }

    //删除
    @DeleteMapping("/{id}")
    public Result deletes(@PathVariable String id){

//        String[] idss = ids.split(",");
//
//        for(String id:idss){
//            empService.deletes(id);
//
//        }

        empService.deletes(id);

        return new Result(true,StatusCode.OK,"删除成功",null);
    }

    @GetMapping("/findall")
    public Result findAll(){

        return new Result(true,StatusCode.OK,"查询成功",empService.findAll());
    }
}
